<?php if (!defined('THINK_PATH')) exit();?><!-- widget grid -->
<section id="widget-grid" class="">

    <!-- row -->
    <div class="row">

        <!-- NEW WIDGET START -->
        <article class="col-sm-12 col-md-12 col-lg-12">

            <!-- Widget ID (each widget will need unique ID)-->
            <div class="jarviswidget" id="wid-id-0" data-widget-deletebutton="false" data-widget-editbutton="false">
                <!-- widget options:
                usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                data-widget-colorbutton="false"
                data-widget-editbutton="false"
                data-widget-togglebutton="false"
                data-widget-deletebutton="false"
                data-widget-fullscreenbutton="false"
                data-widget-custombutton="false"
                data-widget-collapsed="true"
                data-widget-sortable="false"

                -->
                <header>
                    <span class="widget-icon"> <i class="fa fa-edit"></i> </span>
                    <h2><?php echo ($title); ?></h2>

                </header>

                <!-- widget div-->
                <div>

                    <!-- widget edit box -->
                    <div class="jarviswidget-editbox">
                        <!-- This area used as dropdown edit box -->

                    </div>
                    <!-- end widget edit box -->

                    <!-- widget content -->
                    <div class="widget-body">

                        <form class="form-horizontal" id="add" method="post" action="<?php echo U('Exam/addColg');?>">

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-md-2 control-label" for="text-field"><?php echo ($name); ?>名称<b style="color: red"> *</b></label>
                                    <div class="col-md-10">
                                        <input class="form-control" name="name" placeholder="例：理学院" type="text">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-2 control-label" for="textarea"><?php echo ($name); ?>介绍</label>
                                    <div class="col-md-10">
                                        <textarea class="form-control" name="description" placeholder="请输入关于此学院的介绍" rows="4"></textarea>
                                    </div>
                                </div>
                                <input name="pid" value="<?php echo ($pid); ?>" style="display:none;"/>
                            <div class="form-actions">
                                <div class="row">
                                    <div class="col-md-12">
                                        <button class="btn" id="add_reset" type="reset">
                                            <i class="fa fa-refresh"></i>
                                            重置
                                        </button>
                                        <button class="btn btn-primary" type="button" id="add_ok">
                                            <i class="fa fa-save"></i>
                                            确定
                                        </button>
                                    </div>
                                </div>
                            </div>

                        </form>

                    </div>
                    <!-- end widget content -->

                </div>
                <!-- end widget div -->

            </div>
            <!-- end widget -->

        </article>
        <!-- WIDGET END -->

    </div>

    <!-- end row -->

</section>
<!-- end widget grid -->

<!-- SCRIPTS ON PAGE EVENT -->
<script type="text/javascript">

    // DO NOT REMOVE : GLOBAL FUNCTIONS!
    pageSetUp();


    // PAGE RELATED SCRIPTS
    // 输入框获得焦点
    $('#add').find('input:first').focus();
    //form禁用回车提交
    $("#add").on('keydown',function(e){
        if(e.keyCode == 13){
            var $this = $('#add_ok');
            $this.addClass('disabled');
            var post = $("#add").serialize();
            $.ajax({
                type:"POST",
                url:"<?php echo U('Exam/addColg');?>",
                data:post,
                success:function(data){
                    if(data.status == 0){
                        $.smallBox({
                                title : "提示",
                                content : data.info,
                                color : "#D8C74E",
                                timeout: 4000,
                                icon : "fa fa-bell"
                        });                  
                    }else{
                        $.smallBox({
                                title : "成功",
                                content : data.info,
                                color : "#5384AF",
                                timeout: 4000,
                                icon : "fa fa-bell"
                        });
                        location.href = '#<?php echo U("Exam/colg");?>';
                    }                
                }
            });
            $this.removeClass('disabled');            
            return false;
        }
    });

    $("#add_ok").on('click',function(){
        var $this = $(this);
        $this.addClass('disabled');
        var post = $("#add").serialize();
        $.ajax({
            type:"POST",
            url:"<?php echo U('Exam/addColg');?>",
            data:post,
            success:function(data){
                if(data.status == 0){
                    $.smallBox({
                            title : "提示",
                            content : data.info,
                            color : "#D8C74E",
                            timeout: 4000,
                            icon : "fa fa-bell"
                    });                  
                }else{
                    $.smallBox({
                            title : "成功",
                            content : data.info,
                            color : "#5384AF",
                            timeout: 4000,
                            icon : "fa fa-bell"
                    });
                    location.href = '#<?php echo U("Exam/colg");?>';
                }                
            }
        });
        $this.removeClass('disabled');
    })
    
</script>